#include <bits/stdc++.h>
using namespace std;

int n, m, t, a, b, cnt, e[61][2];
vector<int> edge[51];
vector<pair<int, int>> pos[51];

struct Matrix {
    int n, m, a[201][201];
    Matrix(int N, int M)
    {
        n = N, m = M;
        memset(a, 0, sizeof a);
    }
    Matrix operator*(Matrix& b)
    {
        Matrix c(n, b.m);
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= b.m; j++)
                for (int k = 1; k <= m; k++)
                    c.a[i][j] += a[i][k] * b.a[k][j], c.a[i][j] %= 45989;
        return c;
    }
};

Matrix quick_pow(Matrix& a, int k)
{
    Matrix ans(a.n, a.n);
    for (int i = 1; i <= a.n; i++)
        ans.a[i][i] = 1;
    while (k) {
        if (k & 1)
            ans = ans * a;
        a = a * a;
        k >>= 1;
    }
    return ans;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> t >> a >> b;
    a++, b++;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        x++, y++;
        e[i][0] = x, e[i][1] = y;
        edge[x].push_back(i);
        edge[y].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < edge[i].size(); j++)
            pos[i].push_back(make_pair(++cnt, edge[i][j]));
    }
    pos[a].push_back(make_pair(++cnt, -1));
    Matrix A(cnt, cnt);
    for (int i = 1; i <= m; i++) {
        int x = e[i][0], y = e[i][1], id1, id2;
        for (int j = 0; j < pos[x].size(); j++)
            if (pos[x][j].second == i)
                id1 = pos[x][j].first;
        for (int j = 0; j < pos[y].size(); j++)
            if (pos[y][j].second == i)
                id2 = pos[y][j].first;
        for (int j = 0; j < pos[x].size(); j++) {
            if (pos[x][j].second == i)
                continue;
            A.a[id2][pos[x][j].first] = 1;
        }
        for (int j = 0; j < pos[y].size(); j++) {
            if (pos[y][j].second == i)
                continue;
            A.a[id1][pos[y][j].first] = 1;
        }
    }
    Matrix B(cnt, 1);
    B.a[cnt][1] = 1;
    Matrix ANS = quick_pow(A, t) * B;
    int ans = 0;
    for (int i = 0; i < pos[b].size(); i++)
        ans += ANS.a[pos[b][i].first][1], ans %= 45989;
    cout << ans;
    return 0;
}